const app = getApp();
const Controller = require('../controllers/controllers.js').controller;
Page({
  data: {
    isfixed:false,
    listsheight:20,
    aid: "",
    detailData: null,
    productList: [],
    describe: '',
    videoUrl: '',
    thumb: ''
  },
  onLoad(options) {
    let aid = options.id
   this.loadData(aid)
  },
  loadData(aid){
    let _this = this
    Controller.detail({
      'aid': aid,
    }).then(res => {
      let 
      detailData = res.data.detail.data
        detailData.customField.forEach(element => {
        if(element.name == 'describe'){
          _this.setData({
            describe: element.value
          });
        }
        if(element.name == 'video_url'){
          _this.setData({
            videoUrl: element.value
          });
        }
        if(element.name == 'feeds_img'){
          console.log(element.value)
          _this.setData({
            thumb: element.value
          });
        }

      });
  
      _this.setData({
        detailData,
      });
      console.log(detailData)
    }).catch(res=>{

    })
    Controller.case({
      'channel_alias': 'video',
      "apiList": `ekey=1&page=1&video_start_time=history&channel_alias=video&order_by=id`
 }).then(res => {
      let 
      productList = res.data.apiList[1]
      _this.setData({
        productList
      });
      console.log(productList)
    }).catch(res=>{
  
    })

  

  },
  onShow(){
 
  },
  
  onReachBottom(){
    
    
  },
  //页面滚动触发
  onPageScroll(event) {

    let scrollTop = event.scrollTop //页面滚动
    if (scrollTop >= this.data.listsheight) { //页面向上滚动indexKey
      this.setData({
        isfixed:true
      })
    } else { //页面向下滚动
      this.setData({
        isfixed:false
      })
    }
  },
  onShareAppMessage: function (e) {
    
  },
  onShareTimeline: function(res){
    
  },

})